package ooday04work;

public class AnimalTest {
    public static void main(String[] args) {
        Animal [] animals = new Animal[6];
        animals[0] = new Chick("鸡1",9,"红");
        animals[1] = new Dog("狗1",8,"白");
        animals[2] = new Fish("鱼1",7,"黄");
        animals[3] = new Fish("鱼2",6,"紫");
        animals[4] = new Dog("狗2",5,"黑");
        animals[5] = new Chick("鸡2",4,"蓝");

        Master m = new Master();
        for (int i = 0; i <animals.length ; i++) {
            System.out.println(animals[i].color);
            animals[i].eat();
            System.out.println();

            m.feed(animals[i]);

            System.out.println();

            if(animals[i] instanceof Dog){
                Dog dog = (Dog) animals[i];
                dog.lookHome();
            }
            if(animals[i] instanceof Fish){
                Fish fish = (Fish) animals[i];
                fish.swim();
            }
            if(animals[i] instanceof Chick){
                Chick chick = (Chick) animals[i];
                chick.layEggs();
            }
        }
    }
}
